/*
 * @Author: xiehangyun 
 * @Date: 2025-05-16 10:34:07 
 * @Last Modified by: 肖思汗
 * @Last Modified time: 2025-06-27 16:35:39
 */

import { observable, configure } from "mobx";
import aboutUsApi from './AboutUsApi'
import { CompanyInfo } from './AboutUsApi'
import logo from "src/static/smallLogo.png";
configure({ enforceActions: "never" });

// 默认的公司信息
const defaultCompanyInfo: CompanyInfo = {
    name: '浙江凯尚服饰有限公司',
    logo: logo,
    version: 'v1.0.0',
    description: '浙江凯尚服饰有限公司是一家专注于提供高品质设计服务的创新型企业。',
    mission: '通过创新设计，帮助客户实现品牌价值最大化。',
    vision: '成为行业领先的设计服务提供商。',
    contact: {
        address: '北京市朝阳区建国路88号',
        phone: '400-123-4567',
        email: 'contact@threebase.com',
        website: 'www.threebase.com'
    }
};

const aboutUsStore = observable({
    
    companyInfo: defaultCompanyInfo,//公司信息
    loading: false,//加载状态
    error: '',//错误信息
    
    //获取公司信息
    async getInfo() {
        this.loading = true;
        try {
            const res = await aboutUsApi.getCompanyInfo();
            this.companyInfo = res.data || defaultCompanyInfo;
            this.error = '';
        } catch (err) {
            this.error = err.message || '获取公司信息失败';
            this.companyInfo = defaultCompanyInfo;
        } finally {
            this.loading = false;
        }
    },
    
    //提交反馈
    async submitFeedback(data: { content: string; contact?: string }) {
        this.loading = true;
        try {
            await aboutUsApi.submitFeedback(data);
            this.error = '';
        } catch (err) {
            this.error = err.message || '提交反馈失败';
        } finally {
            this.loading = false;
        }
    }

}, {}, { deep: false });

export default aboutUsStore;